package everyday;

import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;

public class T1023 {
    public List<Boolean> camelMatch(String[] queries, String pattern) {
        List<Boolean> res=new ArrayList<>();
        for (int i = 0; i <queries.length ; i++) {
            res.add(dp(queries[i],pattern,0,0));
        }
        return res;

    }

    public boolean dp(String query, String pattern, int queryIndex, int patternIndex) {
        if (patternIndex >= pattern.length()) {
            for (int i = queryIndex; i <query.length() ; i++) {
                if (Character.isUpperCase(query.charAt(i))){
                    return false;
                }
            }
            return true;
        }
        if (queryIndex >= query.length()) return false;
        char c = pattern.charAt(patternIndex);
        boolean res = false;
        for (int i = queryIndex; i < query.length(); i++) {
            char nc=query.charAt(i);
            if (nc == c) {
                res = res ||dp(query,pattern,i+1,patternIndex+1);

            }
            if (Character.isUpperCase(nc)){
                break;
            }
        }
        return res;
    }
    @Test
    public void test() {
//["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"]
//        "FB"
        System.out.println(dp("FoeBa","FB",0,0));
    }
}
